home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
076-100
/
disk_098
/
thai
/
thai.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-05-06
|
3KB
|
140 lines
#include "quiz.h"
extern APTR OpenLibrary ();
struct TextFont * OpenDiskFont ();
LONG IntuiTextLength ();
struct TextAttr thai_textattr;
#define TG_BASEX 4
#define TG_BASEY 12
#define TG_KWIDTH 632
#define TG_WIDTH 16
#define TG_HEIGHT 26
#define TG_GAP 6
struct Gadget thai_gadget[ TC_MAX_CHAR ];
struct IntuiText thai_gtext[ TC_MAX_CHAR ];
UBYTE thai_gtbuf[ TC_MAX_CHAR * 3 ];
init_thai_keyboard ()
{
int c , i , x , y , width;
register struct IntuiText *ip;
register struct Gadget *gp;
struct RastPort rp;
i = 0;
x = TG_BASEX;
y = TG_BASEY;
for ( i = 0; i < TC_MAX_CHAR; i++ ) {
if ( isthai ( i ) ) {
ip = &thai_gtext[ i ];
ip->FrontPen = FP;
ip->BackPen = BP;
ip->DrawMode = JAM1;
ip->TopEdge = 2;
ip->ITextFont = &thai_textattr;
ip->IText = &thai_gtbuf[ i * 3 ];
if ( isreverse(i) ) {
thai_gtbuf[ i * 3 + 0 ] = TC_AW;
thai_gtbuf[ i * 3 + 1 ] = i;
thai_gtbuf[ i * 3 + 2 ] = 0;
}
else {
thai_gtbuf[ i * 3 + 0 ] = i;
thai_gtbuf[ i * 3 + 1 ] = 0;
}
ip->NextText = NULL;
ip->LeftEdge = 0;
width = IntuiTextLength ( ip );
ip->LeftEdge = TG_GAP / 2;
if ( x + width + TG_GAP >= TG_BASEX + TG_KWIDTH ) {
x = TG_BASEX;
y += TG_HEIGHT;
}
gp = &thai_gadget[i];
gp->NextGadget = NULL;
gp->LeftEdge = x;
x += width + TG_GAP;
gp->TopEdge = y;
gp->Width = width + TG_GAP;
gp->Height = TG_HEIGHT;
gp->Flags = GADGHCOMP
#ifdef USE_ON_OFF
| GADGDISABLED
#endif
;
gp->Activation = RELVERIFY;
gp->GadgetType = BOOLGADGET;
gp->GadgetRender = NULL;
gp->SelectRender = NULL;
gp->MutualExclude = 0;
gp->SpecialInfo = NULL;
gp->GadgetID = i;
gp->UserData = NULL;
gp->GadgetText = ip;
AddGadget ( window , gp , (LONG)-1 );
}
}
RefreshGadgets ( window->FirstGadget , window , (LONG)NULL );
}
off_thai_keyboard ()
{
#ifdef USE_ON_OFF
int i;
for ( i = 0; i < TC_MAX_CHAR; i++ )
if ( isthai ( i ) )
OffGadget ( &thai_gadget[i] , window , (LONG)NULL );
#endif
}
on_thai_keyboard ()
{
#ifdef USE_ON_OFF
int i;
for ( i = 0; i < TC_MAX_CHAR; i++ )
if ( isthai ( i ) )
OnGadget ( &thai_gadget[i] , window , (LONG)NULL );
#endif
}
redraw_thai ( field )
int field; /* TW_ENTRY or TS_ENTRY */
{
static struct IntuiText itext =
{ FP , BP , JAM1 , 0 , 0 , NULL , NULL , NULL };
itext.ITextFont = &thai_textattr;
SetAPen ( window->RPort , (LONG)0 );
if ( field == TW_ENTRY ) {
itext.IText = (UBYTE*) screen_word.thai;
RectFill ( window->RPort , (LONG) TWBASEX , (LONG) TWBASEY ,
(LONG) TWBASEX + TWWIDTH - 1 , (LONG)TWBASEY + TWHEIGHT - 1 );
PrintIText ( window->RPort , &itext , (LONG)TWBASEX , (LONG)TWBASEY );
}
else {
itext.IText = (UBYTE*) screen_sentence.thai;
RectFill ( window->RPort , (LONG) TSBASEX , (LONG) TSBASEY ,
(LONG) TSBASEX + TSWIDTH - 1 , (LONG)TSBASEY + TSHEIGHT - 1 );
PrintIText ( window->RPort , &itext , (LONG)TSBASEX , (LONG)TSBASEY );
}
}